package com.bidepan.依赖注入;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestBook {
    @Test
    //基于Set方法进行依赖注入
    public void testSetter() {
        ApplicationContext context1 = new ClassPathXmlApplicationContext("Set和构造器注入.xml");
        Book book1 = (Book) context1.getBean("bookSet", Book.class);
        System.out.println(book1);
    }
    @Test
    //基于构造方法进行依赖注入
    public void testConstructor(){
        ApplicationContext context2 = new ClassPathXmlApplicationContext("Set和构造器注入.xml");
        Book book2 =  context2.getBean("bookCon",Book.class);
        System.out.println(book2);
    }
}
